From 4706b975b068905baf16fbd42d12da825143b25d Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Wed, 27 Jun 2007 21:27:51 +0100 Subject: [PATCH] Small sysctl cleanups. Signed-off-by: Keir Fraser --- xen/common/schedule.c | 8 ++------ xen/common/sysctl.c | 17 +++++++++-------- xen/include/public/sysctl.h | 2 +- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/xen/common/schedule.c b/xen/common/schedule.c index 17443a44f4..7911f5f99c 100644 --- a/xen/common/schedule.c +++ b/xen/common/schedule.c @@ -72,12 +72,8 @@ static inline void vcpu_runstate_change( ASSERT(v->runstate.state != new_state); ASSERT(spin_is_locked(&per_cpu(schedule_data,v->processor).schedule_lock)); - if(unlikely((v->runstate.state_entry_time - new_entry_time) > TIME_SLOP)) - /* Local time on this CPU has been warped */ - v->runstate.time[v->runstate.state] = new_entry_time; - else - v->runstate.time[v->runstate.state] += - new_entry_time - v->runstate.state_entry_time; + v->runstate.time[v->runstate.state] += + new_entry_time - v->runstate.state_entry_time; v->runstate.state_entry_time = new_entry_time; v->runstate.state = new_state; } diff --git a/xen/common/sysctl.c b/xen/common/sysctl.c index 28cbf9b71f..16a6b5fb31 100644 --- a/xen/common/sysctl.c +++ b/xen/common/sysctl.c @@ -140,19 +140,20 @@ long do_sysctl(XEN_GUEST_HANDLE(xen_sysctl_t) u_sysctl) { uint32_t i, nr_cpus; uint64_t idletime; + struct vcpu *v; - nr_cpus = (op->u.cpuinfo.max_cpus > NR_CPUS) ? NR_CPUS : - op->u.cpuinfo.max_cpus; + nr_cpus = min_t(uint32_t, op->u.cpuinfo.max_cpus, NR_CPUS); for ( i = 0; i < nr_cpus; i++ ) { - if(!idle_vcpu[i]) - /* XXX: assumes no further CPUs after first missing one */ + /* Assume no holes in idle-vcpu map. */ + if ( (v = idle_vcpu[i]) == NULL ) break; - /* somewhat imprecise but should suffice */ - idletime = idle_vcpu[i]->runstate.time[RUNSTATE_running] + - (NOW() - idle_vcpu[i]->runstate.state_entry_time); + idletime = v->runstate.time[RUNSTATE_running]; + if ( v->is_running ) + idletime += NOW() - v->runstate.state_entry_time; + if ( copy_to_guest_offset(op->u.cpuinfo.buffer, i, &idletime, 1) ) { ret = -EFAULT; @@ -163,7 +164,7 @@ long do_sysctl(XEN_GUEST_HANDLE(xen_sysctl_t) u_sysctl) op->u.cpuinfo.nr_cpus = i; ret = 0; - if( copy_to_guest (u_sysctl, op, 1) ) + if ( copy_to_guest(u_sysctl, op, 1) ) ret = -EFAULT; } break; diff --git a/xen/include/public/sysctl.h b/xen/include/public/sysctl.h index be20efc4c1..ef467d1304 100644 --- a/xen/include/public/sysctl.h +++ b/xen/include/public/sysctl.h @@ -158,7 +158,7 @@ struct xen_sysctl_cpuinfo { /* IN variables. */ uint32_t max_cpus; XEN_GUEST_HANDLE_64(uint64_t) buffer; - /* IN/OUT variables. */ + /* OUT variables. */ uint32_t nr_cpus; }; typedef struct xen_sysctl_cpuinfo xen_sysctl_cpuinfo_t; -- 2.30.2